#!/bin/bash


# 记住密码
# git config --global credential.helper store

# 远程仓库
# git remote -v


# 手动输入版本号
read -r -p "New file Ver:" new

# 手动输入更新说明
read -r -p "New file Commnt:" commnt

# 写入更新版本号
now="$(date +%Y-%m-%d) $(date +%H:%M:%S)"
sudo sed -i "1s/^/${now} ${new} ${commnt}\n/" iClouds/ver.log

# 停止容器
docker stop resUpload

# 上传到服务器
sudo tar -zcvf resUpload.tar.gz --exclude=/opt/FastPay/.git --exclude=/opt/FastPay/logs --exclude=/opt/FastPay/statics --exclude=/opt/FastPay/.gitignore iClouds
scp resUpload.tar.gz root@lease.3vppt.com:/opt

# 上传到gitee
if [ "$commnt" ]; then
    git add .
    git commit -m "$commnt"
    git push
fi

# 启动容器
docker start resUpload